package com.liuyfly.leetcode.questions;

import lombok.extern.slf4j.Slf4j;

/**
 * @author liuyangfang at 2022-10-21 10:52
 */
@Slf4j
public class Question0191 {
    public static int hammingWeight(int n) {
        int result = 0;
        while (n != 0) {
            if ((n & 1) != 0) {
                result++;
            }
            n >>>= 1;
        }
        return result;
    }

    public static void main(String[] args) {
        int n=-3;
        int result = hammingWeight(n);
        log.info("result:{}", result);
    }
}
